package IOFlow.IOFlowSerializeTheStream.practice;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

public class Test {
    public static void main(String[] args) throws IOException {
        //用对象流读写多个对象
        /*
            将多个自定义地下序列化到文件夹当中，但是由于对象的个数不确定，反序列化流如何读取呢?
         */

        //序列化多个对象
        Student s1=new Student("zhangsan",23,"男");
        Student s2=new Student("lisi",19,"男");
        Student s3=new Student("wangwu",26,"男");

        ArrayList<Student> list=new ArrayList<>();
        list.add(s1);
        list.add(s2);
        list.add(s3);

        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("JavaCase\\Test"));
        oos.writeObject(list);

        oos.close();



    }
}
